// 电影--持久层
var mongoose = require('mongoose');

const get = async () => mongoose.model("movies")
                                    .find()
                                    .sort({_id:-1})
                                    .exec();

const create = async (data) => await mongoose.model("movies").create(data);

const getById = async (_id)=>await mongoose.model("movies").findOne({_id})

const update = async (_id, updateData) => await mongoose.model("movies").updateOne({_id},updateData);

const removeData = async (removeDataId) => await mongoose.model("movies").deleteOne({_id: removeDataId});

module.exports = {get,create,getById,update,removeData}